package com.bit.frige.recipe;

import java.util.ArrayList;

import com.bit.frige.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class RecipeAdapter extends BaseAdapter {

   private Context context;
   private ArrayList<RecipeListDTO> arrData;
   private LayoutInflater inflater;

   public RecipeAdapter(Context c, ArrayList<RecipeListDTO> arr) {
      this.context = c;
      this.arrData = arr;
      inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   }

   public int getCount() {
      return arrData.size();
   }

   public Object getItem(int position) {
      return arrData.get(position).getFoodname();
   }

   public long getItemId(int position) {
      return position;
   }

   public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
         convertView = inflater.inflate(R.layout.rlistlayout, parent, false);
      }

      ImageView img = (ImageView) convertView.findViewById(R.id.adapterimg);
      TextView name = (TextView) convertView.findViewById(R.id.adaptername);
      name.setText(arrData.get(position).getFoodname());
    //  img.setLayoutParams(new LinearLayout.LayoutParams(70, 70));

      if (arrData.get(position).getRecipeNo() == 2001){
         img.setImageResource(R.drawable.recipe1);
      }else if(arrData.get(position).getRecipeNo() == 2002){
         img.setImageResource(R.drawable.recipe2);
      }
      else if(arrData.get(position).getRecipeNo() == 2003){
         img.setImageResource(R.drawable.recipe3);
      }
      else if(arrData.get(position).getRecipeNo() == 2004){
         img.setImageResource(R.drawable.recipe4);
      }
      else if(arrData.get(position).getRecipeNo() == 2005){
         img.setImageResource(R.drawable.recipe5);
      }
      else if(arrData.get(position).getRecipeNo() == 2006){
         img.setImageResource(R.drawable.recipe6);
      }
      else if(arrData.get(position).getRecipeNo() == 2007){
         img.setImageResource(R.drawable.recipe7);
      }
      else if(arrData.get(position).getRecipeNo() == 2008){
         img.setImageResource(R.drawable.recipe8);
      }
      else if(arrData.get(position).getRecipeNo() == 2009){
         img.setImageResource(R.drawable.recipe9);
      }
      else if(arrData.get(position).getRecipeNo() == 2010){
         img.setImageResource(R.drawable.recipe10);
      }
      else if(arrData.get(position).getRecipeNo() == 2011){
         img.setImageResource(R.drawable.recipe11);
      }
      else if(arrData.get(position).getRecipeNo() == 2012){
         img.setImageResource(R.drawable.recipe12);
      }
      else if(arrData.get(position).getRecipeNo() == 2013){
         img.setImageResource(R.drawable.recipe13);
      }
      else if(arrData.get(position).getRecipeNo() == 2014){
         img.setImageResource(R.drawable.recipe14);
      }
      else if(arrData.get(position).getRecipeNo() == 2015){
         img.setImageResource(R.drawable.recipe15);
      }
      else if(arrData.get(position).getRecipeNo() == 2016){
         img.setImageResource(R.drawable.recipe16);
      }
      else if(arrData.get(position).getRecipeNo() == 2017){
         img.setImageResource(R.drawable.recipe17);
      }
      else if(arrData.get(position).getRecipeNo() == 2018){
         img.setImageResource(R.drawable.recipe18);
      }
      else if(arrData.get(position).getRecipeNo() == 2019){
         img.setImageResource(R.drawable.recipe19);
      }
      else if(arrData.get(position).getRecipeNo() == 2020){
         img.setImageResource(R.drawable.recipe20);
      }
      else if(arrData.get(position).getRecipeNo() == 2021){
         img.setImageResource(R.drawable.recipe21);
      }
      

      return convertView;

   }

}
